import { createCrudApi } from '@/utils/apiFactory';
import request from '@/utils/unirequest';
import type { IResult } from '@/type/common';
import type {
  ISysHrProbationRequestBill,
  ISysHrProbationRequestBillView,
  ISysHrProbationRequestBillVm
} from './interface';

export default function SysHrProbationRequestBillApi() {
  // 基础CRUD用工厂生成
  const baseCrud = createCrudApi<
    ISysHrProbationRequestBillView,
    ISysHrProbationRequestBillVm,
    ISysHrProbationRequestBill
  >('/api/SysHrProbationRequestBill');

  return {
    ...baseCrud,
    // 额外的特殊接口
    // 获取单据编号接口
    async getBillCode(): Promise<IResult<string>> {
      return await request.get('/api/SysHrProbationRequestBill/PredictCode');
    },
    // 审核接口
    async approve(data: ISysHrProbationRequestBillVm): Promise<ISysHrProbationRequestBill> {
      return await request.post('/api/SysHrProbationRequestBill/approve?tag=', data);
    },
    // 获取人员信息接口
    async getPersonInfo(): Promise<IResult<any>> {
      return await request.get('/api/_account/getpersoninfo');
    },
  };
}
